package com.youxin.logprocess.bean;

import java.io.File;
import java.net.URI;
import java.util.Locale;

import org.apache.commons.io.FilenameUtils;

import com.youxin.foundation.utils.StringUtils;

/**
 * Nginx请求Bean
 * @author yingde.cao
 *
 */
public class NginxRequestBean {
	private final static String HTM="htm";
	private final static String HTML="html";
	private final static String PHP="php";
	private final static String JSP="jsp";
	
	private String type,url,httpType;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getHttpType() {
		return httpType;
	}

	public void setHttpType(String httpType) {
		this.httpType = httpType;
	}
	
	public boolean isSupportStatics()
	{    	
		String ext=null;
		try {
			File file=new File(url);
			ext=FilenameUtils.getExtension(file.getName());
	    	
		} catch (Exception e) {
			// TODO: handle exception
		}
		if(ext==null)
		{
			try {
				URI uri=new URI(url);
				File file=new File(uri.getPath());
				ext=FilenameUtils.getExtension(file.getName());
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
		if(StringUtils.isNullOrEmpty(ext))
		{
			return true;
		}
		ext=ext.toLowerCase(Locale.US);
		if(HTM.equals(ext)||HTML.equals(ext)||PHP.equals(ext)||JSP.equals(ext))
		{
			return true;
		}
		return false;
	}
	
}
